package com.iflytek.day18;

class Student1 {
  String name;
  int age;

  public Student1(String name, int age) {
    this.name = name;
    this.age = age;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  @Override
  public String toString() {
    System.out.println(getClass().getName() + "@" + Integer.toHexString(hashCode()));
    return "Student1{" +
            "name='" + name + '\'' +
            ", age=" + age +
            '}';
  }
}

public class _11_ObjectDemo {
  public static void main(String[] args) {

    // 创建学生对象
    Student1 s1 = new Student1("iflytek", 14);
    System.out.println(s1);

    // 调用toString方法获取s1对象的字符串表现形式
    String result1 = s1.toString();

    // 输出结果
    System.out.println("s1对象的字符串表现形式为：" + result1);

  }
}
